package com.situ.mall.web.controller;

import com.situ.mall.common.entity.MemberAddress;
import com.situ.mall.common.service.IMemberAddressService;
import com.situ.mall.common.util.RequestUtil;

import com.situ.mall.common.vo.MemberAddressVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/memberaddress")
public class MemberAddressController {
    @Autowired
    private IMemberAddressService memberAddressService;
    @PostMapping("/add")
    @ResponseBody
    public void addAddress(MemberAddress ma){
        ma.setTag("家");
        ma.setMemberId(RequestUtil.getCurrentMemberId());
        memberAddressService.saveOrUpdate(ma);
    }

    @PostMapping("/checkAddress/{id}")
    @ResponseBody
    public MemberAddressVO checkAddress(@PathVariable("id") Integer id){//接到id

        return memberAddressService.checkAddress(id);
    }
    @PostMapping("/deleteAddress/{id}")
    @ResponseBody
    public void deleteAddress(@PathVariable("id") Integer id){//接到id

         memberAddressService.deleteAddress(id);
    }
}
